<!DOCTYPE html>
<html>

<head lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0" />
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="black" name="apple-mobile-web-app-status-bar-style">
    <meta content="telephone=no" name="format-detection">
    <title>传智云购-分类</title>
    <link type="image/x-icon" rel="shortcut icon" href="images/favicon.ico">
    <link rel="stylesheet" href="res/mui/css/mui.min.css" />
    <link rel="stylesheet" href="res/fontAwesome/css/font-awesome.min.css" />
    <link rel="stylesheet" href="css/common.css" />
    <link rel="stylesheet" href="css/cate.css" />
    <style>
        body{
        background:#eee;
    }
    </style>
</head>

<body>
    <div class="cz_layout">
        <header class="cz_topBar">
            <a href="javascript:history.back();" class="icon_back fa fa-arrow-left"></a>
            <form action="javascript:;"><input type="search" placeholder="" /></form>
            <a href="search.html" class="icon_search fa fa-search"></a>
        </header>
        <div class="cz_container">
            <div class="cate_slide">
                <ul>


                </ul>
            </div>
            <div class="cate_content">
                <div class="mui-scroll-wrapper">
                    <div>
                        <span class="title">热门品牌购</span>
                        <ul class="mui-clearfix">
                            <li><a href="#"><img src="images/brand1.png" alt="" />
                                    <p>耐克</p>
                                </a></li>
                            <li><a href="#"><img src="images/brand2.png" alt="" />
                                    <p>耐克</p>
                                </a></li>
                            <li><a href="#"><img src="images/brand3.png" alt="" />
                                    <p>耐克</p>
                                </a></li>
                            <li><a href="#"><img src="images/brand4.png" alt="" />
                                    <p>耐克</p>
                                </a></li>
                            <li><a href="#"><img src="images/brand5.png" alt="" />
                                    <p>耐克</p>
                                </a></li>
                            <li><a href="#"><img src="images/brand6.png" alt="" />
                                    <p>耐克</p>
                                </a></li>
                            <li><a href="#"><img src="images/brand7.png" alt="" />
                                    <p>耐克</p>
                                </a></li>
                            <li><a href="#"><img src="images/brand8.png" alt="" />
                                    <p>耐克</p>
                                </a></li>
                            <li><a href="#"><img src="images/brand1.png" alt="" />
                                    <p>耐克</p>
                                </a></li>
                        </ul>
                        <div class="box"></div>
                    </div>
                </div>
            </div>
        </div>
        <footer class="cz_tabs">
            <a class="tab_home fa fa-home" href="index.html"><span>首页</span></a>
            <a class="tab_cate fa fa-bars now" href="cate.html"><span>分类</span></a>
            <a class="tab_cart fa fa-shopping-cart" href="cart.html"><span>购物车</span></a>
            <a class="tab_user fa fa-user" href="user/index.html"><span>会员中心</span></a>
        </footer>
    </div>
    <!-- 顶级菜单模板引擎 -->
    <script type="text/template" id="tpl">
        {{each rows value}}
            <li data-id="{{value.id}}">{{value.categoryName}}</li>
        {{/each}}
    </script>
    <script type="text/template" id="two">
        <span class="title">{{text}}</span>
        <ul class="mui-clearfix">
            {{each rows value}}
                    <li>
                        <a href="#"><img src="/api{{value.brandLogo}}" alt="" />
                            <p>{{value.brandName}}</p>
                        </a>
                    </li>
            {{/each}}

        </ul>
        
    </script>
    <script src="res/mui/js/mui.min.js"></script>
    <script src="/assets/vendors/jquery/jquery.min.js"></script>
    <script src="/assets/vendors/template-web.js"></script>
    <script>
        mui(function () {
            mui('.mui-scroll-wrapper').scroll({
                scrollY: true, //是否竖向滚动
                scrollX: false, //是否横向滚动
                startX: 0, //初始化时滚动至x
                startY: 0, //初始化时滚动至y
                indicators: false, //是否显示滚动条
                deceleration: 0.0006, //阻尼系数,系数越小滑动越灵敏
                bounce: true, //是否启用回弹
            });
        });
        $.ajax({
            url: '/api/category/queryTopCategory',
            type: 'get',
            success: function (msg) {
                console.log(msg);
                var strHtml = template('tpl', msg);
                $('.cate_slide ul').html(strHtml);
                $('.cate_slide ul li:first-child').trigger('click');
            }
        });
        //点击样式切换



        $('.cate_slide').on('click', 'li', function () {
            // alert(1)
            $(this).addClass('now').siblings().removeClass('now');
            //获取当前li的id
            var id = $(this).attr('data-id');
            var text = $(this).text();
            // 发送ajax
            $.ajax({
                url: '/api/category/querySecondCategory',
                type: 'get',
                data: {
                    id: id
                },
                success: function (msg) {
                    console.log(msg);
                    msg.text = text;
                    var strHtml = template('two', msg);
                    $('.box').html(strHtml);
                }

            });
        })
    </script>
</body>

</html>